let router=require('koa-router')();
let fs=require('fs');

let hah=__dirname;
function sumFile(hah){
    let file=fs.readdirSync(__dirname);
    let filesjs=file.filter(item=>{
        return item.endsWith('.js') && item!='index.js'
    })
    return filesjs
}
function resPath(filesjs){
    filesjs.filter(item=>{
        let obj=require(__dirname+'/'+item)
        for(let key in obj){
            let arr=key.split(' ')
            if(arr[0]=='get'){
                router.get(arr[1],obj[key])
            }else if(arr[0]=='post'){
                router.post(arr[1],obj[key])
            }else if(arr[0]=='delete'){
                router.delete(arr[1],obj[key])
            }else if(arr[0],obj.put){
                router.put(arr[1],obj[key])
            }
        }
    })
}
let s=sumFile;
resPath(s);
module.exports=router.routes();